package com.yst.feign1.controller;

import com.alibaba.fastjson.JSONObject;
import com.yst.feign1.common.ApiResponse;
import com.yst.feign1.feign.TestFeign;
import com.yst.feign1.vo.TestVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("test")
public class OrderController {

    @Autowired
    private TestFeign testFeign;

    @GetMapping("testFeign")
    public String testFeign(@RequestParam String param) {
        log.info("调用feign2前");
        ApiResponse<TestVO> testVO = testFeign.testFeign();
        log.info("调用feign2后");
        log.info(JSONObject.toJSONString(testVO));
        return "200";
    }

    @GetMapping("testFeignError")
    public String testFeignError(@RequestParam String param) {
        log.info("调用feign2前");
//        TestVO testVO = testFeign.throwException();
        log.info("调用feign2后");
//        log.info(JSONObject.toJSONString(testVO));
        return "200";
    }
}
